widget: No longer postpone style-updated on unrealized widgets
authorBenjamin Otte <otte@redhat.com>
Sat, 14 May 2016 16:35:27 +0000 (18:35 +0200)
committerBenjamin Otte <otte@redhat.com>
Sat, 14 May 2016 16:48:22 +0000 (18:48 +0200)
GTK used to not emit GtkWidget::style-updated on widgets that weren't
realized. This sped up construction of complex widgetry in the early
days of GTK3 where we instantly invalidated on every change.
We don't do that anymore, so in theory (and in my limited testing with
widget-factory) this shouldn't be a prolem anymore.

What is a problem though is that postponing style-updated leads to 2
problems:
(1) Unrealized widgets will not emit style-updated which may cause them
    to not properly update their state and return wrong values from
    get_preferred_width/height() etc
(2) Emitting style-updated during realize can happen too late.
    When a widget is not made child-visible by its parent (common
    examples: notebook, paned) it will also not be realized when the
    parent is initially shown. However, when they get realized later
    (after a resize of the parent), they will emit style-updated (and
    potentially queue a resize) during size-allocate.

https://bugzilla.gnome.org/show_bug.cgi?id=765700

gtk/gtkwidget.c
gtk/gtkwidgetprivate.h

index 292a0d980ff6836b5acfb39abdceb64181b4ede1..c14e127be6ae9efdf5fc99b4d4bee09d95a6934b 100644 (file)
@@ -5443,9 +5443,6 @@ gtk_widget_realize (GtkWidget *widget)
       gtk_widget_ensure_style (widget);
       G_GNUC_END_IGNORE_DEPRECATIONS
 
-      if (priv->style_update_pending)
-        g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
-
       g_signal_emit (widget, widget_signals[REALIZE], 0);
 
       gtk_widget_real_set_has_tooltip (widget, gtk_widget_get_has_tooltip (widget), TRUE);
@@ -16495,15 +16492,7 @@ gtk_widget_class_get_css_name (GtkWidgetClass *widget_class)
 void
 _gtk_widget_style_context_invalidated (GtkWidget *widget)
 {
-  if (_gtk_widget_get_realized (widget))
-    g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
-  else
-    {
-      /* Compress all style updates so it
-       * is only emitted once pre-realize.
-       */
-      widget->priv->style_update_pending = TRUE;
-    }
+  g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
 }
 
 GtkCssNode *
index ebee09abee10db25077ca9eb7af8432a95d3e153..e51dd396a577f0a24d4c0940d27705e9ef3e0648 100644 (file)
@@ -66,7 +66,6 @@ struct _GtkWidgetPrivate
   guint receives_default      : 1;
   guint has_grab              : 1;
   guint shadowed              : 1;
-  guint style_update_pending  : 1;
   guint app_paintable         : 1;
   guint double_buffered       : 1;
   guint redraw_on_alloc       : 1;